package mlz.i_stringJoiner;

import java.util.StringJoiner;

//StringJoiner
public class StringJoinerDemo {
    public static void main(String[] args) {
        //新建对象
        StringJoiner s = new StringJoiner(",");//[java1,java2,java3]
        s.add("java1");
        s.add("java2");
        s.add("java3");
        System.out.println(s);

        /*新建对象
            参数1: 间隔符
            参数2: 开头
            参数3: 结束
         */
        StringJoiner s1 = new StringJoiner(",", "[", "]");
        s1.add("java1");
        s1.add("java1");
        s1.add("java1");
        s1.add("java1");
        System.out.println(s1);//[java1,java1,java1,java1]




    }
}








